package com.kuke.pdf;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;


public class ImageTranferTest {

	public static void main(String[] args) {
		try {
			image2PdfPath();
			//image2PdfIn();
			//image2PdfByte();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void image2PdfPath() throws Exception{
		ImageTranfer tranfer = new ImageTranfer();
		List<String> imagePath = new ArrayList<String>();
		imagePath.add("D:\\tmp\\img\\1.jpg");
		imagePath.add("D:\\tmp\\img\\2.jpg");
		imagePath.add("D:\\tmp\\img\\3.jpg");
		imagePath.add("D:\\tmp\\img\\4.jpg");
		byte[] data = tranfer.image2PdfByPath(imagePath);
		FileUtils.writeByteArrayToFile(new File("D:\\tmp\\img\\image2Pdf_path.pdf"), data);
	}
	
	public static void image2PdfIn() throws Exception{
		ImageTranfer tranfer = new ImageTranfer();
		List<InputStream> ins = new ArrayList<InputStream>();
		ins.add(new FileInputStream(new File("D:\\tmp\\img\\1.jpg")));
		ins.add(new FileInputStream(new File("D:\\tmp\\img\\2.jpg")));
		ins.add(new FileInputStream(new File("D:\\tmp\\img\\3.jpg")));
		ins.add(new FileInputStream(new File("D:\\tmp\\img\\4.jpg")));
		byte[] data = tranfer.image2PdfByInputStream(ins);
		FileUtils.writeByteArrayToFile(new File("c:\\tmp\\image2Pdf_in.pdf"), data);
	}
	
	public static void image2PdfByte() throws Exception{
		ImageTranfer tranfer = new ImageTranfer();
		List<byte[]> imageByte = new ArrayList<byte[]>();
		imageByte.add(FileUtils.readFileToByteArray(new File("D:\\tmp\\img\\1.jpg")));
		imageByte.add(FileUtils.readFileToByteArray(new File("D:\\tmp\\img\\2.jpg")));
		imageByte.add(FileUtils.readFileToByteArray(new File("D:\\tmp\\img\\3.jpg")));
		imageByte.add(FileUtils.readFileToByteArray(new File("D:\\tmp\\img\\4.jpg")));
		byte[] data = tranfer.image2PdfByByte(imageByte);
		FileUtils.writeByteArrayToFile(new File("c:\\tmp\\image2Pdf_byte.pdf"), data);
	}
}
